Optimal. Leaf size=65 \[ \frac{a \sin (x)}{a^2+b^2}-\frac{b \cos (x)}{a^2+b^2}+\frac{a b \tanh ^{-1}\left (\frac{a \cos (x)-b \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.0888049, antiderivative size = 65, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 11, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.546, Rules used = {3518, 3109, 2637, 2638, 3074, 206} \[ \frac{a \sin (x)}{a^2+b^2}-\frac{b \cos (x)}{a^2+b^2}+\frac{a b \tanh ^{-1}\left (\frac{a \cos (x)-b \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 3518
Rule 3109
Rule 2637
Rule 2638
Rule 3074
Rule 206
Rubi steps
\begin{align*} \int \frac{\cos (x)}{a+b \cot (x)} \, dx &=-\int \frac{\cos (x) \sin (x)}{-b \cos (x)-a \sin (x)} \, dx\\ &=\frac{a \int \cos (x) \, dx}{a^2+b^2}+\frac{b \int \sin (x) \, dx}{a^2+b^2}+\frac{(a b) \int \frac{1}{-b \cos (x)-a \sin (x)} \, dx}{a^2+b^2}\\ &=-\frac{b \cos (x)}{a^2+b^2}+\frac{a \sin (x)}{a^2+b^2}-\frac{(a b) \operatorname{Subst}\left (\int \frac{1}{a^2+b^2-x^2} \, dx,x,-a \cos (x)+b \sin (x)\right )}{a^2+b^2}\\ &=\frac{a b \tanh ^{-1}\left (\frac{a \cos (x)-b \sin (x)}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac{b \cos (x)}{a^2+b^2}+\frac{a \sin (x)}{a^2+b^2}\\ \end{align*}
Mathematica [A] time = 0.184841, size = 61, normalized size = 0.94 \[ \frac{a \sin (x)-b \cos (x)}{a^2+b^2}-\frac{2 a b \tanh ^{-1}\left (\frac{b \tan \left (\frac{x}{2}\right )-a}{\sqrt{a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A] time = 0.04, size = 81, normalized size = 1.3 \begin{align*} -2\,{\frac{-a\tan \left ( x/2 \right ) +b}{ \left ({a}^{2}+{b}^{2} \right ) \left ( \left ( \tan \left ( x/2 \right ) \right ) ^{2}+1 \right ) }}-4\,{\frac{ab}{ \left ( 2\,{a}^{2}+2\,{b}^{2} \right ) \sqrt{{a}^{2}+{b}^{2}}}{\it Artanh} \left ( 1/2\,{\frac{2\,b\tan \left ( x/2 \right ) -2\,a}{\sqrt{{a}^{2}+{b}^{2}}}} \right ) } \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] time = 2.22042, size = 348, normalized size = 5.35 \begin{align*} \frac{\sqrt{a^{2} + b^{2}} a b \log \left (\frac{2 \, a b \cos \left (x\right ) \sin \left (x\right ) -{\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - a^{2} - 2 \, b^{2} - 2 \, \sqrt{a^{2} + b^{2}}{\left (a \cos \left (x\right ) - b \sin \left (x\right )\right )}}{2 \, a b \cos \left (x\right ) \sin \left (x\right ) -{\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + a^{2}}\right ) - 2 \,{\left (a^{2} b + b^{3}\right )} \cos \left (x\right ) + 2 \,{\left (a^{3} + a b^{2}\right )} \sin \left (x\right )}{2 \,{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F] time = 0., size = 0, normalized size = 0. \begin{align*} \int \frac{\cos{\left (x \right )}}{a + b \cot{\left (x \right )}}\, dx \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A] time = 1.35383, size = 127, normalized size = 1.95 \begin{align*} \frac{a b \log \left (\frac{{\left | 2 \, b \tan \left (\frac{1}{2} \, x\right ) - 2 \, a - 2 \, \sqrt{a^{2} + b^{2}} \right |}}{{\left | 2 \, b \tan \left (\frac{1}{2} \, x\right ) - 2 \, a + 2 \, \sqrt{a^{2} + b^{2}} \right |}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac{3}{2}}} + \frac{2 \,{\left (a \tan \left (\frac{1}{2} \, x\right ) - b\right )}}{{\left (a^{2} + b^{2}\right )}{\left (\tan \left (\frac{1}{2} \, x\right )^{2} + 1\right )}} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]